import 'package:flutter/material.dart';
import 'package:flutter_pink_app/composables/appbar_tabbar.dart';
import 'package:flutter_pink_app/style/text.dart';
import 'ranking_list.dart';

// bili排行页面
class BiliRankingPage extends StatelessWidget {
  final List<Map<String, String>> _tabsInfo = const [
    {"key": "like", "name": "最热"},
    {"key": "pubdate", "name": "最新"},
    {"key": "favorite", "name": "趋势"}
  ]; // 标签页信息

  // 构建顶部导航页
  AppBar _buildAppbar() {
    return AppBar(
      title: buildAppbarTabbar(
          unselectedStyle: normalGrayStyle,
          selectedStyle: mainThemeStyle,
          strList: _tabsInfo.map((info) => info['name']).toList()),
      centerTitle: true,
      shadowColor: Colors.grey[100],
    );
  }

  // 构建主体内容部分
  Widget _buildBody(String text) {
    return RankingList(text);
  }

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: _tabsInfo.length ?? 0,
      child: Scaffold(
          appBar: _buildAppbar(),
          body: TabBarView(
              physics: BouncingScrollPhysics(),
              children:
                  _tabsInfo.map((info) => _buildBody(info['key'])).toList())),
    );
  }
}
